﻿namespace ePubReader
{
    public class Nav
    {
        string source;

        string hash;

        public Nav(string id, string title, string source, Nav[] children)
            : this(id, title, source, 0, children)
        {
        }

        public Nav(string id, string title, string source, int order, Nav[] children)
        {
            hash = string.Empty;

            Id = id;
            Title = title;
            Order = order;
            this.Children = children;

            string[] hs = source.Split(new[] { '#' });
            if (hs.Length == 1)
            {
                this.source = source;
            }
            else if (hs.Length > 1)
            {
                this.source = hs[0];
                hash = hs[1];
            }
        }

        public string Id { get; private set; }

        public string Title { get; private set; }

        /// <summary>
        /// File Source
        /// </summary>
        public string Source
        {
            get { return source; }
            set { source = value; }
        }

        /// <summary>
        /// #hash
        /// </summary>
        public string Hash { get { return hash; } }

        public int Order { get; private set; }

        public Nav[] Children { get; private set; }
    }
}
